//
//  BaseViewModel.h
//  EPTool
//
//  Created by guoshiqing on 2018/4/13.
//  Copyright © 2018年 云数动能科技. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Macro.h"
#import "BaseJSONEntity.h"
#import "Url.h"
#import "BaseJSONService.h"

@interface BaseViewModel : NSObject

@property (copy, nonatomic) GetReturnBlock getReturnBlock;
@property (copy, nonatomic) GetErrorBlock getErrorBlock;
@property (copy, nonatomic) GetFailBlock getFailBlock;
@property (copy, nonatomic) ReturnValueBlock returnBlock;
@property (copy, nonatomic) ErrorCodeBlock errorBlock;
@property (copy, nonatomic) FailureBlock failureBlock;

// 传入交互的Block块
- (void)setBlockWithReturnBlock:(ReturnValueBlock)returnBlock
                 WithErrorBlock:(ErrorCodeBlock)errorBlock
               WithFailureBlock: (FailureBlock)failureBlock;


- (void)getReturnBlockWithReturnBlock:(GetReturnBlock)returnBlock
                       WithErrorBlock:(GetErrorBlock)errorBlock
                        WithFailBlock:(GetFailBlock)failBlock;


// 后台正常返回时的统一处理函数
- (BaseJSONEntity *)fetchValueSuccessWithDic:(id)returnValue andUrl:(NSString *)url;

// 网络请求错误处理
- (void)errorCodeWithDic:(NSError *)errorDic andUrl:(NSString *)url;

// 网络状态异常处理
- (void)netFailureWithUrl:(NSString *)url;

// 发送网络请求
- (void)sendRequestWithUrl:(NSString *)url andParams:(NSMutableDictionary *)params;

// 发送GET网络请求
- (void)getRequestWithUrl:(NSString *)url andParams:(NSMutableDictionary *)params;

@end
